<?
require_once("inc.init.php");

// Gathering already defined Roles
$modules = getAllModules();
$roleActionsFormFields = array();
foreach($modules as $mod)
{
    $ar_permissions = array();
    if (is_array($mod->permissions))
    {
        foreach($mod->permissions as $k=>$v)
        {
            $item = array("xtype"=>"checkbox","width"=>150, "boxLabel"=>$v, "name"=> "perm[".$mod->_moduleID."][".$k. "]");
            $ar_permissions[] = $item;
        }
    }
    $ar_permissions[] = array("xtype"=>"hidden", "name"=> "perm[".$mod->_moduleID."][1]");
    $roleActionsFormFields[] = array("xtype"=>"fieldset", "layout"=>"table",
                          "layoutConfig" => array("columns"=>3),
                          "title"=>$lang->translate($mod->name),
                          items =>$ar_permissions);
}
$roleActionsFormFields[] = array("xtype"=>"hidden", "name"=>"role_id", "value"=>$role->roleID);

// Gathering already defined Roles
$roles = array();
$r = getAllRoles();
foreach($r as $role) $roles[] = $role->roleID;

// Gathering users
$users = array();
$res = mysql_query("SELECT userID, username FROM users", $dbLink);
while($row = mysql_fetch_assoc($res)) $users[] = array($row["userID"], $row["username"]);

?>
AdMin.lang.addWords(<?= json_encode($lang->words) ?>);
AdMin.users = {
    users: <?= json_encode($users) ?>,
    numMaxListedRows: <?= $module->numMaxListedRows ?>,
    roles: <?=json_encode($roles)?>,
    roleActionsFormFields: <?=json_encode($roleActionsFormFields)?>
}

<? include "js/module.js"; ?>
